package com.ruoyi.ap.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ap.domain.Certified;
import com.ruoyi.ap.service.ICertifiedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 认证情况Controller
 * 
 * @author HuaQP
 * @date 2023-10-03
 */
@RestController
@RequestMapping("/ap/certified")
public class CertifiedController extends BaseController
{
    @Resource
    private ICertifiedService certifiedService;

    /**
     * 查询认证情况列表
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:list')")
    @GetMapping("/list")
    public TableDataInfo list(Certified certified)
    {
        startPage();
        List<Certified> list = certifiedService.selectCertifiedList(certified);
        return getDataTable(list);
    }

    /**
     * 导出认证情况列表
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:export')")
    @Log(title = "认证情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Certified certified)
    {
        List<Certified> list = certifiedService.selectCertifiedList(certified);
        ExcelUtil<Certified> util = new ExcelUtil<>(Certified.class);
        util.exportExcel(response, list, "认证情况数据");
    }

    /**
     * 获取认证情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(certifiedService.selectCertifiedById(id));
    }

    /**
     * 新增认证情况
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:add')")
    @Log(title = "认证情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid Certified certified)
    {
        return toAjax(certifiedService.insertCertified(certified));
    }

    /**
     * 修改认证情况
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:edit')")
    @Log(title = "认证情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Valid Certified certified)
    {
        return toAjax(certifiedService.updateCertified(certified));
    }

    /**
     * 删除认证情况
     */
    @PreAuthorize("@ss.hasPermi('ap:certified:remove')")
    @Log(title = "认证情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(certifiedService.deleteCertifiedByIds(ids));
    }
}
